package com.kantboot.business.shop.web.controller;

import com.kantboot.business.shop.domain.entity.BusShopAddressInUserAccount;
import com.kantboot.business.shop.service.IBusShopAddressInUserAccountService;
import com.kantboot.global.rest.result.CommonSuccessStateCodeAndMsg;
import com.kantboot.util.common.result.RestResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户账户中的收货地址控制器
 */
@RestController
@RequestMapping(value = "/business-shop-web/shopAddressInUserAccount")
public class BusShopAddressInUserAccountController {

    @Resource
    private IBusShopAddressInUserAccountService service;

    @RequestMapping("/saveSelf")
    public RestResult<?> saveSelf(@RequestBody BusShopAddressInUserAccount address) {
        service.saveSelf(address);
        return RestResult.success(null, CommonSuccessStateCodeAndMsg.SAVE_SUCCESS);
    }

    @RequestMapping("/getSelf")
    public RestResult<?> getSelf() {
        return RestResult.success(service.getSelf(), CommonSuccessStateCodeAndMsg.GET_SUCCESS);
    }

    @RequestMapping("/deleteSelf")
    public RestResult<?> deleteSelf(@RequestParam("id") Long id) {
        service.deleteSelf(id);
        return RestResult.success(null, CommonSuccessStateCodeAndMsg.OPERATION_SUCCESS);
    }

}
